/**
 * @author 陈泰来
 * @version V1.0
 * @Project echo-java-base
 * @Title 抽象鸭子工厂
 * @Description *
 * @Package designmodel.composite.factory
 * @date 2021/3/2 5:26 下午
 * @Copyright:学如逆水行舟，不进则退 .
 */
package designmodel.composite.factory;

import designmodel.composite.MallardDuck;
import designmodel.composite.Quackable;
import designmodel.composite.RedheadDuck;
import designmodel.composite.DuckCall;
import designmodel.composite.RubberDuck;
import designmodel.composite.observer.Observer;
import designmodel.composite.observer.Quacklogist;
import designmodel.composite.wrapper.QuackWrapper;

public class WrapperDuckFactory extends AbstractDuckFactory {

    //组合观察者
    Quacklogist quacklogist = new Quacklogist();

    @Override
    public Quackable createMallardDuck() {
        MallardDuck mallardDuck = new MallardDuck();
        mallardDuck.registerObserver(quacklogist);
        return new QuackWrapper(mallardDuck);
    }

    @Override
    public Quackable createRedheadDuck() {
        RedheadDuck redheadDuck = new RedheadDuck();
        redheadDuck.registerObserver(quacklogist);
        return new QuackWrapper(redheadDuck);
    }

    @Override
    public Quackable createDuckdCall() {
        DuckCall duckCall = new DuckCall();
        duckCall.registerObserver(quacklogist);
        return new QuackWrapper(duckCall);
    }


    @Override
    public Quackable createRubberDuck() {
        RubberDuck rubberDuck = new RubberDuck();
        rubberDuck.registerObserver(quacklogist);
        return new QuackWrapper(rubberDuck);
    }
}
